package com.wn.pettyloan.service.impl;

import com.wn.pettyloan.entity.Permission;
import com.wn.pettyloan.mapper.PermissionMapper;
import com.wn.pettyloan.service.MenuService;
import com.wn.pettyloan.vo.PermissionVo;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;

/**
 * @program: pettyloan
 * @ClassName MenuServiceImpl
 * @description:
 * @author: 韩旭
 * @create: 2022-12-15 15:32
 **/
@Service
public class MenuServiceImpl implements MenuService {

    @Resource
    private PermissionMapper permissionMapper;

    @Override
    public List<PermissionVo> selectMenuList(String username, Integer pid) {
        List<PermissionVo> permissionVos = permissionMapper.selectMenuList(username,pid);
        if (permissionVos != null) {
            for (PermissionVo permissionVo : permissionVos) {
                List<PermissionVo> permissionVoList = selectMenuList(username, permissionVo.getId());
                permissionVo.setChildren(permissionVoList);
            }
        }
        return permissionVos;
    }

    @Override
    public List<String> selectPermissionByEmpuacc(String username) {
        return permissionMapper.selectPermissionByEmpuacc(username);
    }
}